import request from '@/config/axios'
import type { Dayjs } from 'dayjs'

/** 模具保养项目信息 */
export interface UpkeepItem {
  id: number // 主键
  name?: string // 模具名
  code?: string // 编码
  description: string // 描述
}

// 模具保养项目 API
export const UpkeepItemApi = {
  // 获取所有保养项目
  getItemAll: async () => {
    return await request.get({ url: `/mold/upkeep-item/all` })
  },

  // 查询模具保养项目分页
  getUpkeepItemPage: async (params: any) => {
    return await request.get({ url: `/mold/upkeep-item/page`, params })
  },

  // 查询模具保养项目详情
  getUpkeepItem: async (id: number) => {
    return await request.get({ url: `/mold/upkeep-item/get?id=` + id })
  },

  // 新增模具保养项目
  createUpkeepItem: async (data: UpkeepItem) => {
    return await request.post({ url: `/mold/upkeep-item/create`, data })
  },

  // 修改模具保养项目
  updateUpkeepItem: async (data: UpkeepItem) => {
    return await request.put({ url: `/mold/upkeep-item/update`, data })
  },

  // 删除模具保养项目
  deleteUpkeepItem: async (id: number) => {
    return await request.delete({ url: `/mold/upkeep-item/delete?id=` + id })
  },

  /** 批量删除模具保养项目 */
  deleteUpkeepItemList: async (ids: number[]) => {
    return await request.delete({ url: `/mold/upkeep-item/delete-list?ids=${ids.join(',')}` })
  },

  // 导出模具保养项目 Excel
  exportUpkeepItem: async (params) => {
    return await request.download({ url: `/mold/upkeep-item/export-excel`, params })
  },

  // 获取所有保养项目
  getItemsOfTask: async (id: number) => {
    return await request.get({ url: `/mold/upkeep-task2item/items-of-task?id=${id}` })
  }
}
